package com.bonc.ioc.base.error;

import com.bonc.ioc.common.util.AppReply;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: McpErrorController
 * @Author: Liyy
 * @Description: http请求异常响应格式化处理，将传统的英文错误修改为中文可理解的提示语
 * @Date: 2019-07-12 17:08:44
 **/
@RestController
public class McpErrorController {

    @GetMapping(value = "error/notFind")
    @ApiParam(value = "404异常处理结果")
    public AppReply errorNotFind(){
        return AppReply.error("404","HTTP请求异常：找不到指定资源");
    }

    @GetMapping(value = "error/unAuthorized")
    @ApiParam(value = "401异常处理结果")
    public AppReply unAuthorized(){
        return AppReply.error("401","HTTP请求异常：您访问的资源没有被授权");
    }

    @GetMapping(value = "error/methodNotAllowed")
    @ApiParam(value = "405异常处理结果")
    public AppReply methodNotAllowed(){
        return AppReply.error("405","HTTP请求异常：请求方式不被允许，请对照接口文档检查您的请求方式");
    }

    @GetMapping(value = "error/requestTimeOut")
    @ApiParam(value = "408异常处理结果")
    public AppReply requestTimeOut(){
        return AppReply.error("408","HTTP请求异常：客户端请求超时");
    }

    @GetMapping(value = "error/payloadTooLarge")
    @ApiParam(value = "408异常处理结果")
    public AppReply payloadTooLarge(){
        return AppReply.error("403","HTTP请求异常：请求提过大");
    }

}
